﻿    var FYDM_Array;
    var FYMC_Array;
    var ProceduceName_Array;
    var ProceduceCode_Array;
    var FYDBname_Array;

    var GoingCreating=false;
    var CreatingTitle="正在统计绩效..."
    var SendData_Index;
    var SendData_Total;
    var SendData_Array;
    var CreateErrorInfo;
    var CountError;
    var RedFontTagStr="redFont";
    var GreenFontTagStr = "greedFont";
    var SplitStr ="[&]";
    $(function() {
        FYDM_Array = new Array();
        FYMC_Array = new Array();
        var tempIndex = 0;
        var tempStr = ""
        FYDM_Array[tempIndex] = "2760";
        FYMC_Array[tempIndex++] = "柳州市中级人民法院";
        FYDM_Array[tempIndex] = "2761";
        FYMC_Array[tempIndex++] = "柳州市城中区人民法院";
        FYDM_Array[tempIndex] = "2762";
        FYMC_Array[tempIndex++] = "柳州市鱼峰区人民法院";
        FYDM_Array[tempIndex] = "2763";
        FYMC_Array[tempIndex++] = "柳州市柳南区人民法院";
        FYDM_Array[tempIndex] = "2764";
        FYMC_Array[tempIndex++] = "柳州市柳北区人民法院";
        FYDM_Array[tempIndex] = "2766";
        FYMC_Array[tempIndex++] = "柳江县人民法院";
        FYDM_Array[tempIndex] = "2767";
        FYMC_Array[tempIndex++] = "柳城县人民法院";
        FYDM_Array[tempIndex] = "2814";
        FYMC_Array[tempIndex++] = "鹿寨县人民法院";
        FYDM_Array[tempIndex] = "2818";
        FYMC_Array[tempIndex++] = "融安县人民法院";
        FYDM_Array[tempIndex] = "2820";
        FYMC_Array[tempIndex++] = "融水苗族自治县人民法院";
        FYDM_Array[tempIndex] = "2822";
        FYMC_Array[tempIndex++] = "三江侗族自治县人民法院";

        tempStr = "(公正指标)"; tempIndex = 0;
        ProceduceCode_Array = new Array();
        ProceduceName_Array = new Array();
        ProceduceCode_Array[tempIndex] = "PRO_JX_1_1_LABGL";
        ProceduceName_Array[tempIndex] = "立案变更率" + tempStr; tempIndex++;
        ProceduceCode_Array[tempIndex] = "PRO_JX_1_2_YSAJPSL";
        ProceduceName_Array[tempIndex] = "一审案件陪审率" + tempStr; tempIndex++;
        ProceduceCode_Array[tempIndex] = "PRO_JX_1_3_YSPJAJBGPFHCSL_ALL";
        ProceduceName_Array[tempIndex] = "一审案件陪审率_总表" + tempStr; tempIndex++;
        ProceduceCode_Array[tempIndex] = "PRO_JX_1_4_ESGPFHCSL";
        ProceduceName_Array[tempIndex] = "二审改判发回重审率" + tempStr; tempIndex++;
        ProceduceCode_Array[tempIndex] = "PRO_JX_1_5_ESKTSLL";
        ProceduceName_Array[tempIndex] = "二审开庭审理率" + tempStr; tempIndex++;
        ProceduceCode_Array[tempIndex] = "PRO_JX_1_7_SXAJBGPFHCSL_ZY";
        ProceduceName_Array[tempIndex] = "生效案件被改判发回重审率_中院" + tempStr; tempIndex++;
        ProceduceCode_Array[tempIndex] = "PRO_JX_1_9_ZSSCTZXWTJQKB";
        ProceduceName_Array[tempIndex] = "再审审查询问（听证）率" + tempStr; tempIndex++;
        ProceduceCode_Array[tempIndex] = "PRO_JX_1_10_SFPCL_ALL";
        ProceduceName_Array[tempIndex] = "司法赔偿率_总表" + tempStr; tempIndex++;
        tempStr = "(效率指标)"; 
        ProceduceCode_Array[tempIndex] = "PRO_JX_2_2_YSJYCXSYQKTJB";
        ProceduceName_Array[tempIndex] = "一审简易程序适用率" + tempStr; tempIndex++;
        ProceduceCode_Array[tempIndex] = "PRO_JX_2_3_DTCPL";
        ProceduceName_Array[tempIndex] = "当庭裁判率" + tempStr; tempIndex++;
        ProceduceCode_Array[tempIndex] = "PRO_JX_2_4_FDZCSXNJAL";
        ProceduceName_Array[tempIndex] = "法定（正常）审限内结案率" + tempStr; tempIndex++;
        ProceduceCode_Array[tempIndex] = "PRO_JX_2_7_YCSXWJB";
        ProceduceName_Array[tempIndex] = "延长审限未结比" + tempStr; tempIndex++;
        ProceduceCode_Array[tempIndex] = "PRO_JX_2_8_JAJHD";
        ProceduceName_Array[tempIndex] = "结案均衡度" + tempStr; tempIndex++;
        ProceduceCode_Array[tempIndex] = "PRO_JX_2_9_FYNRJJAS";
        ProceduceName_Array[tempIndex] = "法院年人均结案数" + tempStr; tempIndex++;



        $('#MessageBox').dialog({
            autoOpen: false,
            modal: true,
            width: 500,
            height: 250,
            buttons: {
                "停止": function() {
                    GoingCreating = false;
                    CompleteExecuteAction();
                },
                "关闭": function() {
                    $(this).dialog("close");

                }
            },
            close: function(event, ui) { GoingCreating = false; }
        });
    })

    function SendData(SendData_Index)
       {
           if ((SendData_Index + 1) <= SendData_Total) {
            var dataArray=SendData_Array[SendData_Index].split(SplitStr);
            var fydm_str=dataArray[0];
            var fymc_str = dataArray[1];
            var pro_code_str = dataArray[2];
            var pro_name_str=dataArray[3];
            $('#MessageBoxTempContent').html("<p>(" + (SendData_Index + 1) + "/" + SendData_Total + ") " + fymc_str + "--" + pro_name_str + ":正在统计..." + "<img src='images/wait.gif' id='waitingImg'/>")
            var url = CreateAjaxUrl(fydm_str, pro_code_str);
            $.get(url, { Action: "get", Name: "lulu" }, function(data, textStatus) {
                //                SetMessageBoxTitle(CreateMessageBoxTitle(FZBXHIndex));
                var fontClass = GreenFontTagStr;
                var returnDataArray = data.split(SplitStr);

                var resultMessage = "统计成功。" ;
                if (returnDataArray[0] == "0") {
                    CountError++;
                    CreateErrorInfo += "(" + (SendData_Index + 1) + ") ";
                    fontClass = RedFontTagStr;
                    resultMessage = "统计失败。";
                }

                $('#MessageBoxContent').html("<p>(" + (SendData_Index + 1) + "/" + SendData_Total + ") " + fymc_str + "--" + pro_name_str + ":<span class=\"" + fontClass + "\" >" + resultMessage + "</span></p>" + $('#MessageBoxContent').html());
                SendData_Index++;

                if (GoingCreating) SendData(SendData_Index);
            });
          }
          else{
          // $('#waitingImg').css("display","none");
           if(CountError>0)
           {
             $('#MessageBoxContent').html("<p>共有<span class=\"redFont\">"+CountError+"</span>个统计失败:"+CreateErrorInfo+"。</p>"+$('#MessageBoxContent').html());
           }
           else { }
           CompleteExecuteAction();
          }
      }
      function CompleteExecuteAction() {
          $('#MessageBoxTempContent').html("");
          SetMessageBoxTitle("统计完毕");
      }
    function CreateAjaxUrl(fydm,procedurecode)
    {
       // var CBSPT = "&CBSPT=0";
       var FZBLX="&FZBLX=1";
       var TJYear = "&TJYear=" + GetSelectValue('DropDownListTJYear');
       var TJMonth = "&TJMonth=" + GetSelectValue('DropDownListTJMonthBegin');
       var FYDM = "&FYDM=" + fydm;
       var ProcedureName = "&ProcedureName=" + procedurecode;
       return "CreateJX.ashx?CBSPT=0"  + FZBLX + TJYear + TJMonth + FYDM + ProcedureName;
    }
    function GetSelectValue(selectId)
    {
       var ob=document.getElementById(selectId);
       var length=ob.options.length;
       for(var i=0;i<length;i++)
       {
         if (ob.options[i].selected==true)return ob.options[i].value;
       }
    }

    function CollectSendDatas(fydm,producename)
    {
        
        SendData_Array = new Array();
        var fy_length = FYDM_Array.length;
        var proced_length = ProceduceCode_Array.length;
        
        var senddata_length = 0;
        
        if (fydm == null && producename!=null) {
            for (var i = 0; i < fy_length; i++) {
                for (var j = 0; j < proced_length; j++) {
                    if (producename == ProceduceCode_Array[j]) {
                        SendData_Array[senddata_length++] = FYDM_Array[i] + SplitStr + FYMC_Array[i] + SplitStr + ProceduceCode_Array[j] + SplitStr + ProceduceName_Array[j];
                    }
                }
            }
            
        }
        if (fydm != null && producename == null) {
            
            for (var i = 0; i < fy_length; i++) {
                if (FYDM_Array[i] == fydm.toString()) {
                    for (var j = 0; j < proced_length; j++) {
                    
                        SendData_Array[senddata_length++] = FYDM_Array[i] + SplitStr + FYMC_Array[i] + SplitStr + ProceduceCode_Array[j] + SplitStr + ProceduceName_Array[j];
                        
                    }
                }
                
            }
        }
    }
    
    function CreateJX_Click(fydm, producename)
    {
        
        CollectSendDatas(fydm, producename);
        
       SendData_Total=SendData_Array.length;
       if (SendData_Total > 0)
       {
       
        SetMessageBoxTitle(CreatingTitle);
       // $('#waitingImg').css("display","block");
        $('#MessageBox').dialog("open");
        $('#MessageBoxContent').html("");
        
        GoingCreating=true;
        CreateErrorInfo="";
        CountError=0;
        SendData(0);
       }
       
    }
    function SetMessageBoxTitle(titleStr)
    {
       $('#MessageBox').dialog({title:titleStr});
    }
    function  CreateMessageBoxTitle(index)
    {
      return CreatingTitle+"("+(index+1)+"/"+FZBXH_ArrayLength+")";
    }
    
    function ChangeDataTime()
    {
       var dateStr=$('#TextBox_DateBegin').val();
       var  dateStrs=dateStr.split('-');
       if (dateStrs.length!=3) return false;
       var yearInt= parseInt($('#DropDownList_year').val(),10);
       var monthInt= parseInt($('#DropDownList_month').val(),10);
       var dayNumInt=parseInt(dateStrs[2],10);
       var date1=new Date(monthInt+"-"+dayNumInt+"-"+yearInt+" 00:00:00");
       $('#TextBox_DateBegin').val(formatDate(date1));
       date1.setMonth(date1.getMonth()+1);
       date1.setDate(date1.getDate()-1);
       $('#TextBox_DateEnd').val(formatDate(date1));
    }
    function formatDate(dateOb)
    {
      return dateOb.getFullYear()+"-"+(dateOb.getMonth()+1)+"-"+dateOb.getDate();
  }
  
    
    
    
